package com.example.a22310.myapplication.ViewModel.Post;


import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.example.a22310.myapplication.Beans.user;
import com.example.a22310.myapplication.Listener.PostListener;
import com.example.a22310.myapplication.Model.PostModel;

public class AddLoveNumberViewModel implements PostListener<user> {
    private ActivityPostDetailBinding binding;
    private AppCompatActivity activity;
    private int userid,post_id;


    public AddLoveNumberViewModel(AppCompatActivity activity, ActivityPostDetailBinding binding,
                                  int userid,int post_id){
        this.activity = activity;
        this.binding = binding;
        this.userid = userid;
        this.post_id = post_id;
        binding.setAddlove(this);
    }

    public  void attention(View view){
        PostModel postModel=new PostModel();
        postModel.addLoveNumber(AddLoveNumberViewModel.this,userid,post_id);
    }

    @Override
    public void onSuccess(user user) {
        if (user.getSuccess() == 1 ){
            Toast.makeText(activity,"点赞了",Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public void onFailure() {
        Toast.makeText(activity,"服务器超时",Toast.LENGTH_LONG).show();
    }
}

